import service from "@/utils/request";
import type {HasSpuResponseData} from './interface/interface'
// SPU管理模块
enum API {
   //获取已有的SPU列表数据
    SPULIST = '/admin/product/',
    //获取全部的品牌的数据
    ALLTRADEMARK = '/admin/product/baseTrademark/getTrademarkList',
    //获取已有SPU照片墙的数据
    SPUIMAGE = "/admin/product/spuImageList/",
    //获取已有的SPU销售属性与属性值
    SPUSALEATTR = '/admin/product/spuSaleAttrList/',
    //获取全部的销售属性
    ALLSALEATTR='/admin/product/baseSaleAttrList',
    //添加SPU
    ADDSPU = '/admin/product/saveSpuInfo',
    //更新已有的SPU
    UPDATESPU = '/admin/product/updateSpuInfo',
    //添加SKU方法
    ADDSKU = '/admin/product/saveSkuInfo',
    //获取SKU列表的数据
    SKULIST = '/admin/product/findBySpuId/',
    //删除SPU
    DELETESPU='/admin/product/deleteSpu/'
}
// 获取SPU数据
export const reqHasSpu = (page: number, limit: number, category3Id: number | string) => service.get<any,HasSpuResponseData>(API.SPULIST + `${page}/${limit}?category3Id=${category3Id}`);
//获取全部品牌
export const reqAllTradeMark = () => service.get<any, any>(API.ALLTRADEMARK);
//获取已有的SPU照片墙的数据
export const reqSpuImageList = (spuId: number) => service.get<any, any>(API.SPUIMAGE + spuId);
//获取已有SPU的销售属性的数据
export const reqSaleAttrList = (spuId: number) => service.get<any, any>(API.SPUSALEATTR + spuId);
//获取全部的销售属性
export const reqAllSale = ()=>service.get<any,any>(API.ALLSALEATTR);
// 添加与更新SPU
export const reqAddOrUpdateSpu = (data:any) =>{
    if(data.id){
        return service.post(API.UPDATESPU,data);
    }else{
        return service.post(API.ADDSPU,data);
    }
}
//添加SKU
export const reqAddSku = (data: any) => service.post<any, any>(API.ADDSKU, data);
//获取SKU列表的数据
export const reqSkuList = (spuId: number) => service.get<any, any>(API.SKULIST + spuId);
//删除SPU
export const reqDeleteSpu = (spuId:number)=>service.delete(API.DELETESPU+spuId);





